package br.ufc.apsoo.repositories;

import java.util.List;

import javax.persistence.EntityManager;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Order;

import br.com.caelum.vraptor.ioc.Component;
import br.ufc.apsoo.models.TipoApartamento;

@Component
public class TipoApartamentoRepositoryImpl extends
		Repository<TipoApartamento, Long> implements TodosTiposApartamento {

	private final Session session;

	protected TipoApartamentoRepositoryImpl(EntityManager entityManager) {
		super(entityManager);
		session = (Session) entityManager.getDelegate();
	}

	@Override
	public List<TipoApartamento> lista() {
		Criteria criteria = session.createCriteria(TipoApartamento.class);
		criteria.addOrder(Order.asc("nome"));
		return criteria.list();
	}

}
